﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Kuge.AppSetting;
using SR = Kuge.Resources.Text;

namespace BTS6000
{
    public partial class frmSQL_Setup : Form
    {
        public frmSQL_Setup()
        {
            InitializeComponent();
        }

        private void frmSQL_Setup_Load(object sender, EventArgs e)
        {
            this.Icon = Properties.Resources.Tools;

            Language.ToCHT(this);

            txtDataSource.Text = INI.GetString(SR.SQLServer, SR.DataSource);
            txtInitialCatalog.Text = INI.GetString(SR.SQLServer, SR.InitialCatalog);
            txtUserID.Text = INI.GetString(SR.SQLServer, SR.UserID);
            txtPassword.Text = INI.GetCiphertext(SR.SQLServer, SR.Password);
            rbtnLocal.Checked = INI.GetBoolean(SR.SQLServer, SR.Local, false);
            rbtnRemote.Checked = !rbtnLocal.Checked;

            chkUSESQLServer.Checked = INI.GetBoolean(SR.SQLServer, SR.Enable, false);
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            INI.Set(SR.SQLServer, SR.DataSource, txtDataSource.Text);
            INI.Set(SR.SQLServer, SR.InitialCatalog, txtInitialCatalog.Text);
            INI.Set(SR.SQLServer, SR.UserID, txtUserID.Text);
            INI.SetCiphertext(SR.SQLServer, SR.Password, txtPassword.Text);
            INI.Set(SR.SQLServer, SR.Local, rbtnLocal.Checked);
            INI.Set(SR.SQLServer, SR.Enable, chkUSESQLServer.Checked.ToString());

            this.DialogResult = DialogResult.OK;
        }
    }
}
